<template lang=pug>
    div#productDetail
        div.lineThree
            div.back(@click="back") 返回
            div(v-text="$store.state.currentProduct.ej_good_title")
            div.copy 复制链接
        div.lineTwo
            img(:src="$store.state.currentProduct.ej_good_picture_url",height="200",width="100")
            div.vertical
                span(v-text="'租借价格:'+$store.state.currentProduct.ej_good_rent_price")
                span(v-text="'购买原价:'+$store.state.currentProduct.ej_good_original_price")
                span(v-text="'购买日期:'+$store.state.currentProduct.ej_good_purchasing_date")
                span(v-text="'取货方式:'+$store.state.currentProduct.ej_good_pickup_mode_name")
                span(v-text="'租借时间:'+$store.state.currentProduct.ej_good_rent_time")
        div.info
            span(v-text="'租借人:'+$store.state.currentProduct.ej_good_rent_time")
            span(v-text="'所在位置:'+$store.state.currentProduct.ej_good_rent_time")
            span(v-text="'联系方式:'+$store.state.currentProduct.ej_good_rent_time")
        div.promise
            span(v-text="'协议内容:'+$store.state.currentProduct.ej_good_rent_time")
        div.description
            span(v-text="'描述内容:'+$store.state.currentProduct.ej_good_rent_time")
</template>

<script type="es6">
    export default {
        name: 'productDetail',
        data () {
            return {}
        },
        mounted (){
            console.log(window.location.href);
            const url = window.location.href
            let queryReg = /id=(\w)[\&]*/
            const id = queryReg.exec(url)[1]
            this.$http.get(this.$config.basePath+'/good/getDetailInfo',{
                params:{
                    goodId:id
                }
            }).then(response=>{
                this.$store.commit('updateCurrentProduct',response.data.data)
            })
        },
        methods:{
            back(){
                window.history.go(-1)
            },
            order(id){
                let self = this
                this.$http.post(this.$config.basePath+'/good/orderGood', 'goodId='+ self.$store.state.currentProduct.ej_good_id
                ,{
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                }).then(response=>{
                    console.log(response.data)
                }).catch(error=>{
                    console.log(error)
                })
            }
        },
        components: {}
    }
</script>

<style lang="stylus" scoped>
    #productDetail
        .lineThree
            display flex
            &>div
                flex 1
                text-align center
        .lineTwo
            display flex
            &>div
                flex 1
                text-align center
</style>
